﻿using System;
using System.Windows;
using Unknown.Shared.DisplayMessageBoxes;

namespace Unknown.Shared
{
    public class ApplicationManager
    {
        public static Window ModalParent
        {
            get
            {
                foreach (Window ActiveWindow in Application.Current.Windows)
                {
                    if (ActiveWindow.Topmost)
                        return ActiveWindow;
                }
                return Application.Current.MainWindow;
            }
        }

        public static void DisplayMessageBox(MessageBoxType Title, string Message)
        {
            MessageDisplayUI messageBox = new MessageDisplayUI();
            messageBox.Owner = ApplicationManager.ModalParent;
            messageBox.ShowDialog();            
        }

        public static void HandleException(Exception exception)
        {
            DisplayMessageBox(MessageBoxType.Error, exception.Message);
        }
    }
}
